package com.hm.manage.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hm.common.annotation.Log;
import com.hm.common.core.controller.BaseController;
import com.hm.common.core.domain.AjaxResult;
import com.hm.common.enums.BusinessType;
import com.hm.manage.domain.Xjjl;
import com.hm.manage.service.IXjjlService;
import com.hm.common.utils.poi.ExcelUtil;
import com.hm.common.core.page.TableDataInfo;

/**
 * 巡检记录Controller
 * 
 * @author hm
 * @date 2025-04-07
 */
@RestController
@RequestMapping("/manage/xjjl")
public class XjjlController extends BaseController
{
    @Autowired
    private IXjjlService xjjlService;

    /**
     * 查询巡检记录列表
     */
    @PreAuthorize("@ss.hasPermi('manage:xjjl:list')")
    @GetMapping("/list")
    public TableDataInfo list(Xjjl xjjl)
    {
        startPage();
        List<Xjjl> list = xjjlService.selectXjjlList(xjjl);
        return getDataTable(list);
    }

    /**
     * 导出巡检记录列表
     */
    @PreAuthorize("@ss.hasPermi('manage:xjjl:export')")
    @Log(title = "巡检记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Xjjl xjjl)
    {
        List<Xjjl> list = xjjlService.selectXjjlList(xjjl);
        ExcelUtil<Xjjl> util = new ExcelUtil<Xjjl>(Xjjl.class);
        util.exportExcel(response, list, "巡检记录数据");
    }

    /**
     * 获取巡检记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:xjjl:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(xjjlService.selectXjjlById(id));
    }

    /**
     * 新增巡检记录
     */
    @PreAuthorize("@ss.hasPermi('manage:xjjl:add')")
    @Log(title = "巡检记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Xjjl xjjl)
    {
        return toAjax(xjjlService.insertXjjl(xjjl));
    }

    /**
     * 修改巡检记录
     */
    @PreAuthorize("@ss.hasPermi('manage:xjjl:edit')")
    @Log(title = "巡检记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Xjjl xjjl)
    {
        return toAjax(xjjlService.updateXjjl(xjjl));
    }

    /**
     * 删除巡检记录
     */
    @PreAuthorize("@ss.hasPermi('manage:xjjl:remove')")
    @Log(title = "巡检记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(xjjlService.deleteXjjlByIds(ids));
    }
}
